package com.dbms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dbms.domain.entity.FloodmapSite;
import com.dbms.domain.vo.FloodmapSiteVO;
import com.dbms.mapper.FloodmapSiteMapper;
import com.dbms.service.FloodmapSiteService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class FloodmapSiteServiceImpl implements FloodmapSiteService {

    final FloodmapSiteMapper mapper;

    @Override
    public List<FloodmapSiteVO> getAllList() {
        List<FloodmapSite> list = mapper.selectList(new LambdaQueryWrapper<>());
        List<FloodmapSiteVO> resultList = new ArrayList<>(list.size());
        for (FloodmapSite entity : list) {
            FloodmapSiteVO vo = new FloodmapSiteVO();
            vo.setId(entity.getId());
            vo.setName(entity.getName());
            resultList.add(vo);
        }
        return resultList;
    }

    @Override
    public FloodmapSite getById(String siteId) {
        return mapper.selectById(siteId);
    }
}
